﻿using OpenApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace SuperLottery
{
	[ServiceContract(Name = "Demo")]
	public interface IServiceDemo
	{
		[OperationContract]
		[WebGet(UriTemplate = "user?userid={userid}&a={a}&b={b}")]
		[OpenApiSetting(Openness = ResourceOpenness.Private)]
		string GetUser(int a, int userid, int b);

		[OperationContract]
		[WebGet(UriTemplate = "data?a={a}&b={b}")]
		[OpenApiSetting(Openness = ResourceOpenness.Public)]
		string GetData(int a, int b);

		[OperationContract]
		[WebInvoke(Method = "DELETE", UriTemplate = "data?value={value}")]
		void DeleteData(int value);

		[OperationContract]
		[WebGet(UriTemplate = "datacontract")]
		CompositeType GetDataUsingDataContract();

		[OperationContract]
		[WebInvoke]
		int PostData(int x);

	}

	// 使用下面示例中说明的数据约定将复合类型添加到服务操作。
	[DataContract]
	public class CompositeType
	{
		bool boolValue = true;
		string stringValue = "Hello ";

		[DataMember]
		public bool BoolValue
		{
			get { return boolValue; }
			set { boolValue = value; }
		}

		[DataMember]
		public string StringValue
		{
			get { return stringValue; }
			set { stringValue = value; }
		}
	}
}
